home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / lang / rcs567pc / rcsfront / patches.os2 < prev    next >
Encoding:
Text File  |  1994-11-16  |  23.5 KB  |  863 lines

  1. *** cio.c.orig    Wed Mar 23 15:33:46 1994
  2. --- cio.c    Wed Mar 23 15:28:06 1994
  3. ***************
  4. *** 63,72 ****
  5.   #include <sys/stat.h>
  6.   #include <errno.h>
  7.   #include <signal.h>
  8.   
  9. ! /*--------------------------------------------------- externals ------------*/
  10. ! extern int errno;              /* error code set by system library routines */
  11.   
  12.   extern FILE *fopen();               /* open a stream (should be in stdio.h) */
  13.   extern FILE *popen();                 /* open a pipe (should be in stdio.h) */
  14.   extern char *getenv();                      /* read an environment variable */
  15. --- 63,81 ----
  16.   #include <sys/stat.h>
  17.   #include <errno.h>
  18.   #include <signal.h>
  19. + #include <fcntl.h>
  20.   
  21. ! #ifdef __EMX__
  22. ! #define getcwd _getcwd2
  23. ! #define mkdir(d) mkdir (d, 0755)
  24. ! #endif
  25.   
  26. + #ifndef OS2
  27. + #define stricmp   strcmp
  28. + #define strnicmp  strncmp
  29. + #endif
  30. + /*--------------------------------------------------- externals ------------*/
  31.   extern FILE *fopen();               /* open a stream (should be in stdio.h) */
  32.   extern FILE *popen();                 /* open a pipe (should be in stdio.h) */
  33.   extern char *getenv();                      /* read an environment variable */
  34. ***************
  35. *** 187,199 ****
  36.       register int in;
  37.       register char *cp;        /* used in string updates. */
  38.   
  39.       prognam = justname(argv[0]);    /* program name */
  40.       getdir();            /* go get the enviroment pointers. */
  41.   
  42.       /*
  43.        * figure what the user wants us to be by reading program name
  44.        */
  45. !     if (!strcmp("ciitest", prognam) || !strcmp("cootest", prognam))
  46.       {
  47.           getrcsdir(final, currentdir);    /* setup variables. */
  48.           /*
  49. --- 195,217 ----
  50.       register int in;
  51.       register char *cp;        /* used in string updates. */
  52.   
  53. + #ifdef __EMX__
  54. +     _response(&argc, &argv);
  55. +     _wildcard(&argc, &argv);
  56. +       _emxload_env("RCSLOAD");
  57. + #endif
  58.       prognam = justname(argv[0]);    /* program name */
  59. + #ifdef OS2
  60. +         if ( stricmp(prognam + 3, ".exe") == 0 )
  61. +           prognam[3] = 0;
  62. + #endif
  63.       getdir();            /* go get the enviroment pointers. */
  64.   
  65.       /*
  66.        * figure what the user wants us to be by reading program name
  67.        */
  68. !     if (!stricmp("ciitest", prognam) || !stricmp("cootest", prognam))
  69.       {
  70.           getrcsdir(final, currentdir);    /* setup variables. */
  71.           /*
  72. ***************
  73. *** 211,224 ****
  74.           (void) printf("Final dir:%s:\n", final);
  75.           return(0);
  76.       }
  77. !     if (!strcmp("cii", prognam))    /* this is input.. */
  78.           cii = TRUE;        /* show we are inputs. */
  79. !     else if (strcmp("coo", prognam))/* it's not this either.. */
  80.       {
  81.           (void) printf("Just what did you think this program was, anyway??\n");
  82.           return(-1);
  83.       }
  84.   
  85.       if (!(user_id = geteuid())) /* we are a root process.. */
  86.       {
  87.           (void) umask(027); /* set general mask to private modes. */
  88. --- 228,242 ----
  89.           (void) printf("Final dir:%s:\n", final);
  90.           return(0);
  91.       }
  92. !     if (!stricmp("cii", prognam))    /* this is input.. */
  93.           cii = TRUE;        /* show we are inputs. */
  94. !     else if (stricmp("coo", prognam))/* it's not this either.. */
  95.       {
  96.           (void) printf("Just what did you think this program was, anyway??\n");
  97.           return(-1);
  98.       }
  99.   
  100. + #ifndef OS2        
  101.       if (!(user_id = geteuid())) /* we are a root process.. */
  102.       {
  103.           (void) umask(027); /* set general mask to private modes. */
  104. ***************
  105. *** 234,243 ****
  106.       }
  107.       else
  108.           real_user_id = user_id;    /* else they should match. */
  109.   
  110.       /* prepare for disasters */
  111. !     (void) signal(SIGINT, (int (*)()) sigcleanup);
  112. !     (void) signal(SIGQUIT, (int (*)()) sigcleanup);
  113.   
  114.       cp = cioopt;
  115.       title[0] = '\0';  /* make sure no titles are required. */
  116. --- 252,275 ----
  117.       }
  118.       else
  119.           real_user_id = user_id;    /* else they should match. */
  120. + #else 
  121. +     real_user_id = 1;    /* else they should match. */
  122. + #endif
  123.   
  124.       /* prepare for disasters */
  125. !     (void) signal(SIGINT, sigcleanup);
  126. ! #ifndef OS2
  127. !     (void) signal(SIGQUIT, sigcleanup);
  128. ! #else
  129. !     (void) signal(SIGBREAK, sigcleanup); /* OS/2 */
  130. !     (void) signal(SIGTERM, sigcleanup);  /* signals */
  131. ! #endif
  132. !         if ( argc <= 1 )
  133. !         {
  134. !             usage();
  135. !             return(0);
  136. !         }
  137.   
  138.       cp = cioopt;
  139.       title[0] = '\0';  /* make sure no titles are required. */
  140. ***************
  141. *** 281,287 ****
  142.   #else
  143.           case 'y':        /* they gave us one */
  144.   #endif
  145. !             (void) strcpy(logstr, &argv[in][1]); /* copy across. */
  146.               break;
  147.           case 't':        /* user gave us one */
  148.               (void) strcpy(title, &argv[in][1]);
  149. --- 313,320 ----
  150.   #else
  151.           case 'y':        /* they gave us one */
  152.   #endif
  153. !             (void) strcpy(logstr, " -");
  154. !             (void) strcat(logstr, &argv[in][1]); /* copy across. */
  155.               break;
  156.           case 't':        /* user gave us one */
  157.               (void) strcpy(title, &argv[in][1]);
  158. ***************
  159. *** 374,380 ****
  160.           }
  161.           for ( ; in < argc; in++)
  162.           {
  163. !             (void) sprintf(entry, "%s/%s", currentdir, argv[in]);
  164.   #ifdef DEBUG
  165.               (void) printf("Processing %s\n", entry);
  166.   #endif
  167. --- 407,416 ----
  168.           }
  169.           for ( ; in < argc; in++)
  170.           {
  171. ! #ifdef OS2
  172. !                         UnixFileName(argv[in]);
  173. ! #endif
  174. !             (void) sprintf(entry, "%s%s", currentdir, argv[in]);
  175.   #ifdef DEBUG
  176.               (void) printf("Processing %s\n", entry);
  177.   #endif
  178. ***************
  179. *** 406,412 ****
  180.               ;
  181.           for ( ; in < argc; in++)
  182.           {
  183. !             (void) sprintf(ep, "/%s", argv[in]);
  184.   #ifdef DEBUG
  185.               (void) printf("Processing %s\n", entry);
  186.   #endif
  187. --- 442,451 ----
  188.               ;
  189.           for ( ; in < argc; in++)
  190.           {
  191. ! #ifdef OS2
  192. !                         UnixFileName(argv[in]);
  193. ! #endif
  194. !             (void) sprintf(ep, "%s", argv[in]);
  195.   #ifdef DEBUG
  196.               (void) printf("Processing %s\n", entry);
  197.   #endif
  198. ***************
  199. *** 438,444 ****
  200. --- 477,489 ----
  201.       FILE *pp;
  202.       char *cmd, *entry;
  203.   
  204. +         if ( dir[strlen(dir) - 1] == '/' )
  205. +           dir[strlen(dir) - 1] = 0;
  206. + #ifdef OS2
  207. +     (void) sprintf(cmd = memalloc(strlen(dir) + 10), "dir /b \"%s\"", dir);
  208. + #else
  209.       (void) sprintf(cmd = memalloc(strlen(dir) + 4), "ls %s", dir);
  210. + #endif
  211.       pp = popen(cmd, "r");
  212.       free(cmd);
  213.       if (!pp)
  214. ***************
  215. *** 506,512 ****
  216.           if (noexec)
  217.           {
  218.               (void) printf("Logfile entry bypassed.\n");
  219. !             (void) strcpy(logstr, " ");    /* fake it */
  220.           }
  221.           else if (!getfinput(titlest, TYPE_LOG)) /* if we entered anything */
  222.           {
  223. --- 551,557 ----
  224.           if (noexec)
  225.           {
  226.               (void) printf("Logfile entry bypassed.\n");
  227. !             (void) strcpy(logstr, "");    /* fake it */
  228.           }
  229.           else if (!getfinput(titlest, TYPE_LOG)) /* if we entered anything */
  230.           {
  231. ***************
  232. *** 570,576 ****
  233.           if (access(final, 0))    /* it's not here... */
  234.               if (!makedir(final))    /* so try and make it. */
  235.               {
  236. !                 (void) printf("Could not create directory :%s:\n", final);
  237.                   return(FALSE);
  238.               }
  239.           *st = '/';    /* restore the rest of the file name. */
  240. --- 615,621 ----
  241.           if (access(final, 0))    /* it's not here... */
  242.               if (!makedir(final))    /* so try and make it. */
  243.               {
  244. !                 (void) printf("Could not create directory: %s:\n", final);
  245.                   return(FALSE);
  246.               }
  247.           *st = '/';    /* restore the rest of the file name. */
  248. ***************
  249. *** 625,634 ****
  250.               (void) printf("%s already exists.  Overwrite? (yes) ", final);
  251.               (void) strrd(cmdbuf, 20, stdin);
  252.               (void) strlwr(cmdbuf);
  253. !             if (strncmp(cmdbuf, "yes", strlen(cmdbuf)))
  254.                   return(TRUE);
  255.           }
  256. !         (void) sprintf(cmdbuf, "cp %s %s", filename, final); /* copy command */
  257.       }
  258.       else if (cii)
  259.       {
  260. --- 670,679 ----
  261.               (void) printf("%s already exists.  Overwrite? (yes) ", final);
  262.               (void) strrd(cmdbuf, 20, stdin);
  263.               (void) strlwr(cmdbuf);
  264. !             if (strnicmp(cmdbuf, "yes", strlen(cmdbuf)))
  265.                   return(TRUE);
  266.           }
  267. !         (void) sprintf(cmdbuf, "cp -p %s %s", filename, final); /* copy command */
  268.       }
  269.       else if (cii)
  270.       {
  271. ***************
  272. *** 712,718 ****
  273.               if (!*st)
  274.                   (void) strcpy(st, "yes");
  275.               (void) strlwr(st);
  276. !             if (!strncmp(st, "yes", strlen(st))) {
  277.                   done = TRUE;
  278.                   (void) system(cmdbuf);    /* do it. */
  279.               }
  280. --- 757,763 ----
  281.               if (!*st)
  282.                   (void) strcpy(st, "yes");
  283.               (void) strlwr(st);
  284. !             if (!strnicmp(st, "yes", strlen(st))) {
  285.                   done = TRUE;
  286.                   (void) system(cmdbuf);    /* do it. */
  287.               }
  288. ***************
  289. *** 725,731 ****
  290.                   (void) printf("?       Print this message\n");
  291.                   (void) printf("\n");
  292.               }
  293. !             else if (!strncmp(st, "view", strlen(st)))
  294.               {
  295.                   (void) printf("Not implemented yet!\n\n");
  296.               }
  297. --- 770,776 ----
  298.                   (void) printf("?       Print this message\n");
  299.                   (void) printf("\n");
  300.               }
  301. !             else if (!strnicmp(st, "view", strlen(st)))
  302.               {
  303.                   (void) printf("Not implemented yet!\n\n");
  304.               }
  305. ***************
  306. *** 737,743 ****
  307.       {
  308.   #endif /* INTERACTIVE */
  309.           if (verbose)
  310. !             (void) printf("%s command :%s:\n", prognam, cmdbuf);
  311.           if (!noexec)
  312.           {
  313.               if (do_copy && !verbose)
  314. --- 782,788 ----
  315.       {
  316.   #endif /* INTERACTIVE */
  317.           if (verbose)
  318. !             (void) printf("%s command: %s:\n", prognam, cmdbuf);
  319.           if (!noexec)
  320.           {
  321.               if (do_copy && !verbose)
  322. ***************
  323. *** 749,765 ****
  324.   #ifdef INTERACTIVE
  325.       }
  326.   #endif /* INTERACTIVE */
  327.       if (updsrcdir)            /* update source directory */
  328.       {
  329.           getsrcdir(final, filename);
  330. !         (void) sprintf(cmdbuf, "cp %s %s", filename, final);
  331.           if (noexec)        /* don't actual do it */
  332.               (void) printf("%s\n", cmdbuf);
  333.           else
  334.           {
  335.               if (verbose)    /* speak, yo wise one! */
  336. !                 (void) printf("%s command :%s:\n", prognam, cmdbuf);
  337. !             if (!strcmp(filename, final))
  338.                   (void) printf("Source and destination identical.  Not updated.\n");
  339.               else
  340.               {
  341. --- 794,824 ----
  342.   #ifdef INTERACTIVE
  343.       }
  344.   #endif /* INTERACTIVE */
  345.       if (updsrcdir)            /* update source directory */
  346.       {
  347.           getsrcdir(final, filename);
  348. !             if (st = strrchr(final, '/'))    /* if this has a sub dir. */
  349. !             {
  350. !                 *st = '\0';    /* terminate it at the directoy level. */
  351. !                 if (access(final, 0))    /* it's not here... */
  352. !                     if (!makedir(final))    /* so try and make it. */
  353. !                     {
  354. !                         (void) printf("Could not create directory: %s:\n", final);
  355. !                         return(FALSE);
  356. !                     }
  357. !                 *st = '/';    /* restore the rest of the file name. */
  358. !             }
  359. !         (void) sprintf(cmdbuf, "cp -p %s %s", filename, final);
  360.           if (noexec)        /* don't actual do it */
  361.               (void) printf("%s\n", cmdbuf);
  362.           else
  363.           {
  364.               if (verbose)    /* speak, yo wise one! */
  365. !                 (void) printf("%s command: %s:\n", prognam, cmdbuf);
  366. !             if (!stricmp(filename, final))
  367.                   (void) printf("Source and destination identical.  Not updated.\n");
  368.               else
  369.               {
  370. ***************
  371. *** 852,874 ****
  372.           char *header;        /* header template file name. */
  373.       } ftype[] = {
  374.   #ifdef V_RCS
  375. !         { "c program",    ".rcshead.c"    },    /* FTYPE_C */
  376. !         { "assembler",    ".rcshead.s"    },    /* FTYPE_S */
  377. !         { "command",    ".rcshead.sh"    },    /* FTYPE_SH */
  378. !         { "roff, tbl",    ".rcshead.roff"    },    /* FTYPE_ROFF */
  379. !         { "fortran",    ".rcshead.f"    },    /* FTYPE_F */
  380. !         { 0,        ".rcshead"    },    /* FTYPE_DEFAULT */
  381. !         { 0,        ".rcshead.mk"    },    /* FTYPE_MK */
  382. !         { 0,        ".rcshead.h"    } };    /* FTYPE_H */
  383. ! #else
  384. !         { "c program",    ".sccshead.c"    },    /* FTYPE_C */
  385. !         { "assembler",    ".sccshead.s"    },    /* FTYPE_S */
  386. !         { "command",    ".sccshead.sh"    },    /* FTYPE_SH */
  387. !         { "roff, tbl",    ".sccshead.roff"},    /* FTYPE_ROFF */
  388. !         { "fortran",    ".sccshead.f"    },    /* FTYPE_F */
  389. !         { 0,        ".sccshead"    },    /* FTYPE_DEFAULT */
  390. !         { 0,        ".sccshead.mk"    },    /* FTYPE_MK */
  391. !         { 0,        ".sccshead.h"    } };    /* FTYPE_H */
  392.   #endif /* V_RCS */
  393.       static struct _fext {
  394.           char *name;
  395. --- 911,933 ----
  396.           char *header;        /* header template file name. */
  397.       } ftype[] = {
  398.   #ifdef V_RCS
  399. !         { "c program",    "rcshead.c"    },    /* FTYPE_C */
  400. !         { "assembler",    "rcshead.s"    },    /* FTYPE_S */
  401. !         { "command",    "rcshead.sh"    },    /* FTYPE_SH */
  402. !         { "roff, tbl",    "rcshead.rof"    },    /* FTYPE_ROFF */
  403. !         { "fortran",    "rcshead.f"    },    /* FTYPE_F */
  404. !         { 0,        "rcshead"    },    /* FTYPE_DEFAULT */
  405. !         { 0,        "rcshead.mk"    },    /* FTYPE_MK */
  406. !         { 0,        "rcshead.h"    } };    /* FTYPE_H */
  407. ! #else
  408. !         { "c program",    "sccshead.c"    },    /* FTYPE_C */
  409. !         { "assembler",    "sccshead.s"    },    /* FTYPE_S */
  410. !         { "command",    "sccshead.sh"    },    /* FTYPE_SH */
  411. !         { "roff, tbl",    "sccshead.rof"},    /* FTYPE_ROFF */
  412. !         { "fortran",    "sccshead.f"    },    /* FTYPE_F */
  413. !         { 0,        "sccshead"    },    /* FTYPE_DEFAULT */
  414. !         { 0,        "sccshead.mk"    },    /* FTYPE_MK */
  415. !         { 0,        "sccshead.h"    } };    /* FTYPE_H */
  416.   #endif /* V_RCS */
  417.       static struct _fext {
  418.           char *name;
  419. ***************
  420. *** 933,939 ****
  421.           if (ext = strrchr(fname, '.'))
  422.           {
  423.               for (i = 0; fext[i].name; i++)
  424. !                 if (!strcmp(ext, fext[i].name))
  425.                       ft = fext[i].type;
  426.           }
  427.           else
  428. --- 992,998 ----
  429.           if (ext = strrchr(fname, '.'))
  430.           {
  431.               for (i = 0; fext[i].name; i++)
  432. !                 if (!stricmp(ext, fext[i].name))
  433.                       ft = fext[i].type;
  434.           }
  435.           else
  436. ***************
  437. *** 946,952 ****
  438.       }
  439.       else if (ft == FTYPE_C)        /* see if source or header */
  440.       {
  441. !         if ((ext = strrchr(fname, '.')) && !strcmp(ext, ".h"))
  442.               ft = FTYPE_H;
  443.       }
  444.       if (verbose)            /* is this necessary */
  445. --- 1005,1011 ----
  446.       }
  447.       else if (ft == FTYPE_C)        /* see if source or header */
  448.       {
  449. !         if ((ext = strrchr(fname, '.')) && !stricmp(ext, ".h"))
  450.               ft = FTYPE_H;
  451.       }
  452.       if (verbose)            /* is this necessary */
  453. ***************
  454. *** 965,971 ****
  455.       strcpy(tempfile, t_name);
  456.       ext = justname(tempfile); /* find end of path. */
  457.       *ext = '\0'; /* and terminate path there. */
  458. !     (void) strcat(tempfile, "ciotmp._XXXXXX"); /* add tmp name */
  459.       (void) mktemp(tempfile);        /* generate temp file name */
  460.       if (!(ofp = fopen(tempfile, "w")))    /* open temp file */
  461.       {
  462. --- 1024,1030 ----
  463.       strcpy(tempfile, t_name);
  464.       ext = justname(tempfile); /* find end of path. */
  465.       *ext = '\0'; /* and terminate path there. */
  466. !     (void) strcat(tempfile, "ctXXXXXX"); /* add tmp name */
  467.       (void) mktemp(tempfile);        /* generate temp file name */
  468.       if (!(ofp = fopen(tempfile, "w")))    /* open temp file */
  469.       {
  470. ***************
  471. *** 997,1007 ****
  472. --- 1056,1072 ----
  473.   */
  474.       if(!err && !unlink(t_name))    /* 'mv tempfile fname' */
  475.       {           
  476. + #ifndef OS2                
  477.           if(!link(tempfile, t_name)) /* 'cp tempfile t_name' */
  478.               (void) unlink(tempfile);        /* 'rm tempfile' */
  479.           else
  480.               (void) printf("Link of %s and %s failed after removing %s.\n%s not removed.\n",
  481.                   tempfile, t_name, t_name, tempfile);
  482. + #else
  483. +         if(!rename(tempfile, t_name)) /* 'cp tempfile t_name' */
  484. +             (void) printf("Rename of %s to %s failed after removing %s.\n%s not removed.\n",
  485. +                 tempfile, t_name, t_name, tempfile);
  486. + #endif
  487.       }
  488.       else
  489.       {
  490. ***************
  491. *** 1024,1040 ****
  492.       register char *st, *cp;
  493.   
  494.       if(!*newpath) return(FALSE); /* skip last directory attempt. */
  495. -     cp = memalloc(strlen(newpath) + 24);
  496. -     (void) sprintf(cp, "/bin/mkdir %s 2>/dev/null", newpath);
  497. -     if(verbose)
  498. -         (void) printf("calling mkdir: %s\n", cp);
  499.       if (noexec)
  500.       {
  501. !         (void) printf("%s\n", cp);
  502. !         free(cp);
  503.           return(TRUE);
  504.       }
  505. !     if (system(cp))            /* it failed.. */
  506.       {
  507.           (void) strcpy(cp, newpath);    /* get current one. */
  508.           st = strrchr(cp, '/'); /* remove one more layer.. */
  509. --- 1089,1105 ----
  510.       register char *st, *cp;
  511.   
  512.       if(!*newpath) return(FALSE); /* skip last directory attempt. */
  513.       if (noexec)
  514.       {
  515. !         (void) printf("mkdir: %s\n", newpath);
  516.           return(TRUE);
  517.       }
  518. !     else if(verbose)
  519. !         (void) printf("mkdir: %s\n", newpath);
  520. !     cp = memalloc(strlen(newpath) + 24);
  521. !     if (mkdir(newpath))            /* it failed.. */
  522.       {
  523.           (void) strcpy(cp, newpath);    /* get current one. */
  524.           st = strrchr(cp, '/'); /* remove one more layer.. */
  525. ***************
  526. *** 1043,1055 ****
  527.           {
  528.               free(cp);
  529.               return(FALSE);
  530. !         } /* ok, so.. it passed on back. Try this again. */
  531. !         else if(makedir(newpath) == FALSE)
  532.           {
  533.               free(cp);
  534.               return(FALSE);
  535.           }
  536.       }
  537.       free(cp);
  538.       return(TRUE);
  539.   }
  540. --- 1108,1122 ----
  541.           {
  542.               free(cp);
  543.               return(FALSE);
  544. !         }
  545. !                 /* ok, so.. it passed on back. Try this again. */
  546. !         if(mkdir(newpath))
  547.           {
  548.               free(cp);
  549.               return(FALSE);
  550.           }
  551.       }
  552.       free(cp);
  553.       return(TRUE);
  554.   }
  555. ***************
  556. *** 1057,1062 ****
  557. --- 1124,1130 ----
  558.   /*--------------------------------------------------- strstr() --------------
  559.   / find a substring within a string
  560.   /---------------------------------------------------------------------------*/
  561. + #ifndef OS2
  562.   char *
  563.   strstr(s1, s2)
  564.   register char *s1, *s2;
  565. ***************
  566. *** 1084,1089 ****
  567. --- 1152,1158 ----
  568.               *s = _tolower(*s);
  569.       return(op);
  570.   }
  571. + #endif
  572.   
  573.   /*--------------------------------------------------- asciifile() -----------
  574.   / check if passed file is an ascii file using file(1) command
  575. ***************
  576. *** 1095,1100 ****
  577. --- 1164,1183 ----
  578.       char cmdstr[256];
  579.       register FILE *fp;
  580.   
  581. + #ifdef OS2
  582. +         int file, cnt, i;
  583. +     if ((file = open(fn, O_RDONLY|O_BINARY)) == -1)
  584. +         return(FALSE);
  585. +     cnt = read(file, cmdstr, sizeof(cmdstr)); /* get a block. */
  586. +     close(file);    /* and done. */
  587. +         for ( i = 0; i < cnt; i++ )
  588. +                 if ( cmdstr[i] == 0 || cmdstr[i] == 127 )
  589. +                     return(FALSE);
  590. +         return(TRUE);
  591. + #else /* OS2 */
  592.       (void) sprintf(cmdstr, "file %s", fn);
  593.       if (!(fp = popen(cmdstr, "r")))
  594.           return(FALSE);
  595. ***************
  596. *** 1106,1111 ****
  597. --- 1189,1195 ----
  598.       if (strstr(ftypestr, "text"))
  599.           return(TRUE);
  600.       return(FALSE);
  601. + #endif /* OS2 */
  602.   }
  603.   
  604.   /*--------------------------------------------------- rcsfile() -------------
  605. ***************
  606. *** 1118,1123 ****
  607. --- 1202,1218 ----
  608.       char cmdstr[256];
  609.       register FILE *fp;
  610.   
  611. + #ifdef OS2
  612. +     if (!(fp = fopen(fn, "r")))
  613. +         return(FALSE);
  614. +     (void) strrd(ftypestr, 80, fp); /* get a line. */
  615. +     (void) fclose(fp);    /* and done. */
  616. + #ifdef DEBUG
  617. +     (void) printf("%s\n", cmdstr);
  618. + #endif
  619. +     if (strcmp(ftypestr, "head     "))
  620. +         return(TRUE);
  621. + #else /* OS2 */
  622.       (void) sprintf(cmdstr, "file %s", fn);
  623.       if (!(fp = popen(cmdstr, "r")))
  624.           return(FALSE);
  625. ***************
  626. *** 1132,1137 ****
  627. --- 1227,1233 ----
  628.       if (strstr(ftypestr, "sccs"))
  629.   #endif
  630.           return(TRUE);
  631. + #endif /* OS2 */
  632.       return(FALSE);
  633.   }
  634.   
  635. ***************
  636. *** 1263,1268 ****
  637. --- 1359,1369 ----
  638.           (void) fprintf(stderr, "Cannot get working dir.\n");
  639.           exit(-1);
  640.       }
  641. + #ifdef OS2
  642. +         /* strcpy(currentdir, currentdir + 2); */
  643. +         UnixFileName(currentdir);
  644. + #endif
  645. +         strcat(currentdir, "/");
  646.       s_currentdir = strlen(currentdir);
  647.   }
  648.   
  649. ***************
  650. *** 1280,1285 ****
  651. --- 1381,1390 ----
  652.       register char *cp, *dp;
  653.       register int was_slash = FALSE;
  654.   
  655. + #ifdef OS2
  656. +         UnixFileName(cs);
  657. + #endif
  658.       cp = dp = cs;
  659.       while (isspace(*cp))        /* remove leading white spaces */
  660.           cp++;
  661. ***************
  662. *** 1324,1333 ****
  663.   {
  664.       register char *cp = sdir;
  665.   
  666. !     if(rcswrk && !strncmp(rcswrk, cp, s_rcswrk))
  667.           cp += s_rcswrk;
  668. !     if(homedir && !strncmp(homedir, cp, s_homedir))
  669.           cp += s_homedir;
  670.       /*
  671.        * build the final directory name
  672.        */
  673. --- 1429,1444 ----
  674.   {
  675.       register char *cp = sdir;
  676.   
  677. !     if(rcswrk && !strnicmp(rcswrk, cp, s_rcswrk))
  678.           cp += s_rcswrk;
  679. !     if(homedir && !strnicmp(homedir, cp, s_homedir))
  680.           cp += s_homedir;
  681. + #ifdef OS2
  682. +         if(isalpha(cp[0]) && cp[1] == ':')
  683. +                 cp += 2;
  684. + #endif
  685. +         if(cp[0] == '/')
  686. +                 cp++;
  687.       /*
  688.        * build the final directory name
  689.        */
  690. ***************
  691. *** 1343,1350 ****
  692.   {
  693.       register char *cp = sdir;
  694.   
  695. !     if (rcsdir && !strncmp(rcsdir, cp, s_rcsdir))
  696.           cp += s_rcsdir;
  697.       (void) sprintf(tdir, "%s%s", rcswrk ? rcswrk : homedir, cp);
  698.   }
  699.   
  700. --- 1454,1467 ----
  701.   {
  702.       register char *cp = sdir;
  703.   
  704. !     if (rcsdir && !strnicmp(rcsdir, cp, s_rcsdir))
  705.           cp += s_rcsdir;
  706. + #ifdef OS2
  707. +         if(isalpha(cp[0]) && cp[1] == ':')
  708. +                 cp += 2;
  709. + #endif
  710. +         if(cp[0] == '/')
  711. +                 cp++;
  712.       (void) sprintf(tdir, "%s%s", rcswrk ? rcswrk : homedir, cp);
  713.   }
  714.   
  715. ***************
  716. *** 1357,1366 ****
  717.   {
  718.       register char *cp = sdir;
  719.   
  720. !     if (rcsdir && !strncmp(rcsdir, cp, s_rcsdir))
  721. !         cp += s_rcsdir;
  722. !     if(homedir && !strncmp(homedir, cp, s_homedir))
  723.           cp += s_homedir;
  724.       (void) sprintf(tdir, "%s%s", srcdir ? srcdir : homedir, cp);
  725.   }
  726.   
  727. --- 1474,1489 ----
  728.   {
  729.       register char *cp = sdir;
  730.   
  731. !     if (rcswrk && !strnicmp(rcswrk, cp, s_rcswrk))
  732. !         cp += s_rcswrk;
  733. !     if(homedir && !strnicmp(homedir, cp, s_homedir))
  734.           cp += s_homedir;
  735. + #ifdef OS2
  736. +         if(isalpha(cp[0]) && cp[1] == ':')
  737. +                 cp += 2;
  738. + #endif
  739. +         if(cp[0] == '/')
  740. +                 cp++;
  741.       (void) sprintf(tdir, "%s%s", srcdir ? srcdir : homedir, cp);
  742.   }
  743.   
  744. ***************
  745. *** 1375,1380 ****
  746. --- 1498,1504 ----
  747.       int stat_loc;
  748.   
  749.       (void) strcpy(name, tmpnam(editfile));
  750. + #ifndef OS2
  751.       if (fork())
  752.       {    /* parent just waits for the child to finish */
  753.           (void) wait(&stat_loc);
  754. ***************
  755. *** 1383,1397 ****
  756.       {    /* child does his/her stuff */
  757.           (void) signal(SIGINT, SIG_DFL);
  758.           (void) signal(SIGQUIT, SIG_DFL);
  759.           exit(child_getfinput(name, type) == TRUE ? 0 : -1);
  760.       }
  761.       return((stat_loc >> 8) & 0xff);
  762.   }
  763.   
  764.   /*--------------------------------------------------- child_getfinput() -----
  765.   / actual get title file.
  766.   /---------------------------------------------------------------------------*/
  767. ! static int
  768.   child_getfinput(name, type)
  769.   char *name;        /* buffer to put file name into. */
  770.   int type;        /* what data we want. */
  771. --- 1507,1526 ----
  772.       {    /* child does his/her stuff */
  773.           (void) signal(SIGINT, SIG_DFL);
  774.           (void) signal(SIGQUIT, SIG_DFL);
  775. +         (void) signal(SIGBREAK, SIG_DFL);
  776. +         (void) signal(SIGTERM, SIG_DFL);
  777.           exit(child_getfinput(name, type) == TRUE ? 0 : -1);
  778.       }
  779.       return((stat_loc >> 8) & 0xff);
  780. + #else
  781. +     return child_getfinput(name, type) == TRUE ? 0 : -1;
  782. + #endif
  783.   }
  784.   
  785.   /*--------------------------------------------------- child_getfinput() -----
  786.   / actual get title file.
  787.   /---------------------------------------------------------------------------*/
  788. ! int
  789.   child_getfinput(name, type)
  790.   char *name;        /* buffer to put file name into. */
  791.   int type;        /* what data we want. */
  792. ***************
  793. *** 1402,1408 ****
  794. --- 1531,1539 ----
  795.       int c, done = FALSE;
  796.       char buf[82];            /* just larger than input buffer. */
  797.                     
  798. + #ifndef OS2
  799.       (void) setuid(real_user_id);        /* user's real user id */
  800. + #endif        
  801.       if((fp = fopen(name, "w")) == NULL) /* failed open. */
  802.       {
  803.           (void) unlink(name);        /* remove it. */
  804. ***************
  805. *** 1410,1416 ****
  806.           (void) printf("Unable to create tmp file.\n");
  807.           return(FALSE);
  808.       }
  809. !     (void) printf("Enter %s message, <ret>.<ret> or Control-D to end:\n",
  810.           input_type[type]);
  811.       while (!done)
  812.       {
  813. --- 1541,1547 ----
  814.           (void) printf("Unable to create tmp file.\n");
  815.           return(FALSE);
  816.       }
  817. !     (void) printf("Enter %s message, <ret>.<ret> or Control-Z to end:\n",
  818.           input_type[type]);
  819.       while (!done)
  820.       {
  821. ***************
  822. *** 1535,1540 ****
  823. --- 1666,1674 ----
  824.   {
  825.       register char *cp;
  826.   
  827. + #ifdef OS2
  828. +         UnixFileName(fpath);
  829. + #endif
  830.       if (cp = strrchr(fpath, '/'))
  831.           return(++cp);
  832.   
  833. ***************
  834. *** 1617,1619 ****
  835. --- 1751,1764 ----
  836.   }
  837.   
  838.   /*----------------------------- End of cio.c -------------------------------*/
  839. + #ifdef OS2
  840. + UnixFileName(char *name)
  841. + {
  842. +   /* strlwr(name); */
  843. +   for ( ; *name; name++ )
  844. +     if ( *name == '\\' )
  845. +       *name = '/';
  846. + }
  847. + #endif
  848.